<?php
    include APPLICATION_PATH . '/application/views/head.phtml';
    include APPLICATION_PATH . '/application/views/top.phtml';
    include APPLICATION_PATH . '/application/views/left.phtml';
?>
<script src="/public/js/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>
<script>

$(function() {
    $.ajax({
        type: "post",
        contentType: "application/json",
        url: "/Article/address",
        data: "{}",
        success: function(result) {
            var str = '';
            for (var i = 0; i < result.length; i++) {
                str += '<option value="' + result[i]['sid'] + '" data-url="' + result[i]['url'] + '" data-id="' + result[i]['siteid'] + '" data-ip="' + result[i]['ip'] + '" data-number="' + result[i]['port_number'] + '" >' + result[i]['name'] + '</option>';
            }

            $('#push_address').append(str);
        }
    });
    $('#push_address').change(function() {

        $.ajax({
            type: "post",

            url: "/Article/module",

            data: {
                "siteid": $(this).val()
            },
            dataType : 'JSON',
            success: function(result) {
                $('#pushOne_Module option').remove();
                var str = '<option value="0" >请选择推送的栏目</option>';
                if(result != null){
                    for (var i = 0; i < result.length; i++) {
                        var category = result[i].split(",");
                        str += '<option value="' + category[1] + '" >' + category[0] + '</option>';
                    }
                }
                $('#pushOne_Module').append(str);
            },
            error: 　 function(err) {
                alert('error');
                console.log(err);
            }
        });
    });
});
$(document).ready(function() {

    var __ArtiForm = $('#form_article_add');
    var __editForm = $('#form_modal_edit');

    // $('.tableDelete').click(function(){
    $(document).on('click', '.tableDelete', function() {
        var userId = $(this).parent('td').attr('item_id'),
            thisUrl = $(this).attr('href');
        //官网欢迎页   
        layer.confirm('确认删除', {
            btn: ['确认', '取消'] //按钮
        }, function(index) {

            $.ajax({
                type: "GET",
                url: thisUrl,
                async: true,
                data: {
                    //"id" : userId
                },
                success: function(data) {
                    layer.alert(data.info, function() {
                        if (true === data.status) window.location = "/Article/list";
                    });
                }
            });
            layer.close(index);
            return false;

        }, function(index) {
            layer.close(index);
        });
        return false;

    });


    //$('.tableEdit').click(function(e){
    $(document).on('click', '.tableEdit', function(e) {

        $.ajax({
            type: "POST",
            url: "/Article/edit/id/" + urlId,
            data: {
                "name": objAuthForm.__formName.val(),
                "sites_id": 　objAuthForm.__formUrl.val()
                    // "create_time" :　objAuthForm.__formTime.val(),

            },
            success: function(data) {
                layer.alert(data.info, function() {
                    if (true === data.status) window.location = "/Category/list";
                });
            },
            error: function(error) {
                alert('error');
            }
        });
        //window.location = "/Article/edit";

    });


    $('#pushBtn').click(function(e) {

//var str="[p]fff[/p]";
//str=str.replace(/\[/g,'<').replace(/\]/g,'>');
//str=str.replace(/\'/g,"’");//替换半角单引号为全角单引号
//str=str.replace(/\"/g,"”");//替换半角双引号为全角双引号
//str=str.replace(/\[.*?\]/g,"<>");//
//alert(str);
        if($('#current_table input[name="checkBox"]:checked').length == 0){
            layer.alert('请选择要推送的文章');
            return false;
        }

        $('#article_li').empty();
        $('#article_content').empty();
        $('#current_table input[name="checkBox"]:checked').each(function() {
            var arr = [];
            var tit = $(this).data('tit');
            var content = $(this).data('content');
            var author = $(this).data('author');
            var source = $(this).data('source');
            var time = $(this).data('time');
            var picture = $(this).data('picture');
            var id = $(this).data('id');
            $('#article_li').append($('<option data-id="' + id + '" value="' + id + '">' + tit + '</option>'));
            $('#article_content').append($('<option data-id="' + id + '" value="' + id + '">' + content + '</option>'));
            $('#article_author').append($('<option data-id="' + id + '" value="' + id + '">' + author + '</option>'));
            $('#article_source').append($('<option data-id="' + id + '" value="' + id + '">' + source + '</option>'));
            $('#article_time').append($('<option data-id="' + id + '" value="' + id + '">' + time + '</option>'));
            $('#article_picture').append($('<option data-id="' + id + '" value="' + id + '">' + picture + '</option>'));
        });
        var checkBoxs = {

        }

    });

    $('#chose1').click(function() {
        $('#current_table input[name="checkBox"]').attr('checked', 'checked');
        $('#current_table input[name="checkBox"]').parent('span').addClass('checked');
        return false;
    })
    $('#chose2').click(function() {
        $('#current_table input[name="checkBox"]').each(function() {
            if ($(this).parent('span').hasClass('checked')) {
                $(this).removeAttr('checked');
                $(this).parent('span').removeClass('checked');
            } else {
                $(this).attr('checked', '');
                $(this).parent('span').addClass('checked');
            }

        })
        return false;
    })
    
    $('#search').click(function() {
        var search_info = $("input[name=demo]").val();
        //alert(search_info);
        $.ajax({
            type: "post",

            url: "/Article/search",

            data: {"search_info": search_info},
            dataType : 'JSON',
            success: function(result) {
                //console.log(result);
                $('#pushOne_Module option').remove();
                var str = '<option value="0" >请选择推送的栏目</option>';
                if(result != null){
                    for (var i = 0; i < result.length; i++) {
                        var category = result[i].split(",");
                        str += '<option value="' + category[1] + '" >' + category[0] + '</option>';
                    }
                }
                $('#pushOne_Module').append(str);
                
            },
            error: 　 function(err) {
                alert('error');
                console.log(err);
            }
        });
        return false;
    
    })
   //var exampleSocket = new WebSocket("ws://118.145.2.103:9502");
   var exampleSocket = new WebSocket("ws://59.110.12.245:9501");
     exampleSocket.onopen = function(event) {
     //exampleSocket.send("hello i'm client!");
        layer.msg("服务器连接成功！");
     };
 
   exampleSocket.onclose = function()
        {
          // layer.msg("服务器断开连接！");
        };

    exampleSocket.onmessage = function(event) {
        
          //alert(event.data);
          //console.log(aa['status']);
         // layer.alert(event.data, function(){
         //    window.location = "/Article/list";
         // });
        var info   = event.data.split(",");
        $.ajax({
            type: 'POST',
            url: '/Article/pushStatus',
            dataType : 'JSON',
            data: {"article_info":event.data},
            success: function(data) {
                layer.alert(data.info, function() {
                    if (true === data.status) window.location = "/Article/list";
                });
            },
            error: function(err) {

            }
        })
        //return false;
    }

        $('#push_form').click(function() {
            var siteid = $('#push_address option:selected').data('id');
        objArtiForm = {
            //__formName : $("input[name='name']", __editForm),
            __formName: $("select[name='push_address']", __editForm),
            __formOne: $("select[name='push_Module']", __editForm),
            //__formTwo: $("select[name='pushModule']", __editForm),
            __formArticle: $("select[name='article_li']", __editForm),
            __formContent: $("select[name='article_content']", __editForm),
            __formAuthor: $("select[name='article_author']", __editForm),
            __formSource: $("select[name='article_source']", __editForm),
            __formTime: $("select[name='article_time']", __editForm),
            __formpicture: $("select[name='article_picture']", __editForm),
            __formPush: $("input[name='push_time_input']", __editForm),
            __formUrl: $("input[name='article_url']", __editForm)
        }
        if(objArtiForm['__formName'].val() == 0){
            layer.alert('请输入推送的网站');
                return false;
        }
        var urlone = $('#push_address option:selected').data('url');
        var ip     = $('#push_address option:selected').data('ip').trim();
         //alert(ip);
        var port_number = $('#push_address option:selected').data('number');
           //alert(port_number);
        articleId = document.getElementById('article_li');
        var pushcon = {};
        pushcon.articleId = {};
        pushcon.articleTitle = {};
        pushcon.timing = $('input[name="push_style"]:checked').val();
        pushcon.address = $('#push_address option:selected').val();
        pushcon.oneModel = $('#pushOne_Module option:selected').val();
        if(pushcon.oneModel == 0){
            layer.alert('请输入推送的栏目');
                return false;
        }

        if(pushcon.timing == 1){
            var odata = new Date();
            pushcon.time = odata.getFullYear() + '-' + parseInt(odata.getMonth()+1) + '-' + odata.getDate() + ' ' + odata.getHours() + ':' + odata.getMinutes() + ':' + odata.getSeconds();
        }else if(pushcon.timing == 2){
            pushcon.time = $('#push_time_input').val();
        }else{
            pushcon.time = '';
            console.log('时间设置有误');
        }


        for (i = 0; i < articleId.length; i++) {
            selectId    = articleId.options[i].value;
            selectTitle = articleId.options[i].text;
            pushcon.articleId[i]    = selectId;
            pushcon.articleTitle[i]    = selectTitle;
            //alert(selectTitle);
        }

        var content = {};
        for (var i in objArtiForm) {
            if (objArtiForm[i].text() == ''  ) {
                objArtiForm[i].css({
                    'border-color': 'red'
                });
            }
            else if(objArtiForm['__formName'].val() == '--请选择推送的网站--' ){
                objArtiForm['__formName'].css({
                    'border-color': 'red'
                });
                layer.alert('请选择要推送的网站');
                return false;
            }
             else {
                objArtiForm[i].css({
                    'border-color': '#e5e5e5'
                });
            }
        }

        var $selectedvalue = $("input[name='push_style']:checked").val();
        if ($selectedvalue == 1) {
            for(var i = 0 ; i < $('#article_li option').length; i++){

                content[i]                = new Object();
                content[i]['article_id']  = $('#article_li option').eq(i).val();
                content[i]['siteid']      = siteid;
                content[i]['catid']       = objArtiForm['__formOne'].val();
                content[i]['title']       = $('#article_li option').eq(i).text();
               // content[i]['content']   = $('#article_content option').eq(i).text();
                content[i]['username']    = $('#article_author option').eq(i).text();
                content[i]['source']      = $('#article_source option').eq(i).text();
                content[i]['inputtime']   = $('#article_time option').eq(i).text();
                content[i]['picture']     = $('#article_picture option').eq(i).text();
                content[i]['url']         = urlone; 
                content[i]['ip']          = ip;
                content[i]['port_number'] = port_number;
                content[i]['article_url'] = objArtiForm['__formUrl'].val();
                //content[i]['content'] =$('#article_content option').eq(i).text();
                var str = $('#article_content option').eq(i).text();
                content[i]['content']=str.replace(/\[/g,'<').replace(/\]/g,'>');

            
                //alert(content[i]['content']);
                /*var str = $('#article_content option').eq(i).text();
                var reg = new RegExp('\\[&(.+?)\\]',"g");
                var res =  str.replace(reg,"&emsp;");
               // content[i]['content']=res.replace(/\[/g,'<').replace(/\]/g,'>')
                content[i]['content'] = res.replace(/\[/g,'<').replace(/\]/g,'>').replace(/\<img>/g,'<img src="').replace(/\<\/img>/g,'"/>').replace(/\<p><text-align:center>/g,'<p style="text-align:center";>');*/


        };
            console.log(content);
            var jsonStr = JSON.stringify(content);
            exampleSocket.send(jsonStr);
        }
        if ($selectedvalue == 2) {
            //alert(objArtiForm['__formPush'].val());
            for(var i = 0 ; i < $('#article_li option').length; i++){

                content[i]                = new Object();
                content[i]['article_id']  = $('#article_li option').eq(i).val();
                content[i]['siteid']      = siteid;
                content[i]['catid']       = objArtiForm['__formOne'].val();
                content[i]['title']       = $('#article_li option').eq(i).text();
                //content[i]['content']   = $('#article_content option').eq(i).text();
                content[i]['username']    = $('#article_author option').eq(i).text();
                content[i]['source']      = $('#article_source option').eq(i).text();
                content[i]['inputtime']   = $('#article_time option').eq(i).text();
                content[i]['picture']     = $('#article_picture option').eq(i).text();
                content[i]['pushtime']    = objArtiForm['__formPush'].val();
                content[i]['url']         = urlone;
                content[i]['ip']          = ip;
                content[i]['port_number'] = port_number;
                content[i]['article_url'] = objArtiForm['__formUrl'].val();
                //content[i]['content'] =$('#article_content option').eq(i).text();
                var str = $('#article_content option').eq(i).text();
                content[i]['content']=str.replace(/\[/g,'<').replace(/\]/g,'>');



                //alert(content[i]['content']);
               //  var str = $('#article_content option').eq(i).text();
               //  var reg = new RegExp('\\[&(.+?)\\]',"g");
               //  var res =  str.replace(reg,"&emsp;");
               // // content[i]['content']=res.replace(/\[/g,'<').replace(/\]/g,'>')
               //  content[i]['content'] = res.replace(/\[/g,'<').replace(/\]/g,'>').replace(/\<img>/g,'<img src="').replace(/\<\/img>/g,'"/>');


    
        };
        
            console.log(content);
            
            var jsonStr = JSON.stringify(content);
            exampleSocket.send(jsonStr);
        }

        //alert($('#push_time_input').val());
        if($('#uniform-timer>span').hasClass('checked')){
            var inputvalue = $('#push_time_input').val();
            var currentDate = new Date();
            var odata = {};
            odata.y = currentDate.getFullYear();
            odata.m = currentDate.getMonth()+1;
            odata.d = currentDate.getDate();
            odata.h = currentDate.getHours();
            odata.ms = currentDate.getMinutes();
            odata.s = currentDate.getSeconds();
            var nowtime = odata.y + '-' + odata.m + '-' + odata.d + ' ' + odata.h + ':' + odata.ms + ':' + odata.s;
            //alert(nowtime);

            if(inputvalue == ''){
                layer.alert('请输入推送时间');
                return false;
            }
            if(CompareDate(nowtime, inputvalue) ){
                layer.alert('推送时间必须大于当前时间');
                return false;
            };
            
        }
        function CompareDate(d1,d2){
            return ((new Date(d1.replace(/-/g,"\/"))) > (new Date(d2.replace(/-/g,"\/"))));
        } 

        var jsonPushCon = JSON.stringify(pushcon);
        $.ajax({
            type: 'POST',
            url: '/Article/pushTime',
            dataType : 'JSON',
            data: jsonPushCon,
            success: function(data) {
                //layer.alert(data.info, function() {
                //    if (true === data.status) window.location = "/Article/list";
                //});
            },
            error: function(err) {

            }
        })


    });
  

    $(document).on('click', '#page_next,#page_prev,#page_index,#page_end', function() {
        var urlOld = $(this).attr('href'),
            urlArr = urlOld.split("/"),
            catid = $('#type_select').val();
        var channel_id = $("#channel_select").val();
        var statu_1 = $('#status_1').is(':checked') ? 1 : 0;
        var statu_2 = $('#status_2').is(':checked') ? 1 : 0;
        if(statu_1 == 1 ){
            var status = 0;
        }
        else if(statu_2 == 1 ){
            var status = 2;
        }           
        urlId = urlArr[urlArr.length - 1];
        $.ajax({
            type: 'POST',
            url: '/Article/page/page/' + urlId,
            data: { 'urlId':urlId, 'typical_id':catid, 'status':status,"channel_id":channel_id},
            success: function(data) {
                var data = $.parseJSON(data);

                $('#tbody').html('');
                var id = '';

                $.each(data, function(k, v) {

                    id = v['article_id'];
                    //console.log("k" + k, "v" + v);
                    //alert(v['article_content']);

                    $('#tbody').append($("<tr class='gradeX'><td><div class='check'><span><input name='checkBox' type='checkbox' class='selectCheckBox' data-id='"+v['article_id']+"'data-tit='"+v['title']+"' data-content='" + v['article_content']+"'data-author='"+v['author']+"'  data-source='"+v['source']+"'data-time='"+v['current_time']+"' data-push='"+v['push_time']+"' data-picture='"+v['thumb']+"'></span></div><a class='modalbtn_art' data-toggle='modal' href='#art_con_modal'>" + v['title']+'</a>'+ v['pic'] + "</td><td>" + v['name'] + "</td><td>" + v['chanel'] + "</td><td>" + v['author'] + "</td><td>" + v['source'] + "</td><td>" + v['article_status'] + "</td><td>" + v['current_time'] + "</td><td ><a class='tableDelete' href='/Article/del/id/" + id + "'>删除</a> / <a class='tableEdit' href='/Article/edit/id/" + id + "'>修改</a> </td></tr>"));
                });


            }

        });
        $.ajax({
            type: 'POST',
            url: '/Article/currentPage/page/' + urlId,
            data: { 'urlId':urlId, 'typical_id':catid , 'status':status,"channel_id":channel_id},
            success: function(data) {
                console.log(data);
                $('#pages').html(data);
                $('#pages').ready(function() {
                    nextBtn = $('#page_next');
                });
            }

        });
        return false;
    });



    $(".m-wrap").change(function() {
        //确定选中的是那个，得到他的value
        var $selectedvalue = $("input[name='push_style']:checked").val();
        if ($selectedvalue == 1) {
            //显示 下面的input            
            $("#push_module").show();
            $("#push_address").show();
            $("#push_time").hide();
        }
        if ($selectedvalue == 2) {
            $("#push_module").show();
            $("#push_address").show();
            $("#push_time").show();
        }
    });

    $(document).on('click', '.modalbtn_art', function(){
        var _infobox = $(this).parent('td').find('input.selectCheckBox');
        var content =_infobox.data('content').replace(/\[/g,'<').replace(/\]/g,'>');
       // alert(content);
        $('#modal_tit').html(_infobox.data('tit'));
        $('#modal_con').html(content);
    })
    $("#type_select ,#status_1, #status_2,#channel_select").on('change', function(){
        //alert($("#channel_select").val());
        var item_id    = $("#type_select").val();
        var channel_id = $("#channel_select").val();
        var statu_1    = $('#status_1').is(':checked') ? 1 : 0;
        var statu_2    = $('#status_2').is(':checked') ? 1 : 0;
        if(statu_1 == 1 ){
            var status = 0;
        }
        else if(statu_2 == 1 ){
            var status = 2;
        }
        $.ajax({
            type: 'POST',
            url: '/Article/list',
            data: {"typical_id":item_id,"status":status,"channel_id":channel_id},
            success: function(data) {
               // alert(data);
                var jsonData = $.parseJSON(data);
                
                $('#tbody').html('');
                var id         = '';
                var rows       ='';
                var every_page ='';
                var page       ='';
                if(jsonData == ""){
                    $('#pages').html('');
                }

                $.each(jsonData, function(k, v) {
                    
                    id         = v['article_id'];
                    page       =  v['page'];
                    rows       = v['rows'];
                    every_page =  v['every_page'];

                    $('#tbody').append($("<tr class='gradeX'><td><div class='check'><span><input name='checkBox' type='checkbox' class='selectCheckBox' data-id='"+v['article_id']+"'data-tit='"+v['title']+"' data-content='" + v['article_content']+"'data-author='"+v['author']+"'  data-source='"+v['source']+"'data-time='"+v['current_time']+"' data-push='"+v['push_time']+"' data-picture='"+v['thumb']+"'></span></div><a class='modalbtn_art' data-toggle='modal' href='#art_con_modal'>" + v['title']+'</a>'+ v['pic'] + "</td><td>" + v['name'] + "</td><td>" + v['chanel'] + "</td><td>" + v['author'] + "</td><td>" + v['source'] + "</td><td>" + v['article_status'] + "</td><td>" + v['current_time'] + "</td><td ><a class='tableDelete' href='/Article/del/id/" + id + "'>删除</a> / <a class='tableEdit' href='/Article/edit/id/" + id + "'>修改</a> </td></tr>"));
                });
                if(rows/every_page<=1){
                    $('#pages').html('');
                }else{
                    $('#pages').html(page);
                }

            }

        });
        return false;
    });


$('#type_select').change(function() {

        $.ajax({
            type: "post",

            url: "/Article/chanel",

            data: {
                "article_type_id": $(this).val()
            },
            dataType : 'JSON',
            success: function(result) {
                //console.log(result);
                $('#channel_select option').remove();
                var str = '<option value="0" >请选择频道</option>';
                    for (var i = 0; i < result.length; i++) {
                        str += '<option value="' + result[i]['name'] + '" >' + result[i]['remark'] + '</option>';
                    }
                $('#channel_select').append(str);
            },
            error: 　 function(err) {
                alert('error');
                console.log(err);
            }
        });
    });


});
    </script>

 <div id="thispage" data-id="31"></div>
       <!-- BEGIN PAGE -->

        <div class="page-content">

            <!-- BEGIN SAMPLE PORTLET CONFIGURATION MODAL FORM-->

            <div id="portlet-config" class="modal hide">

                <div class="modal-header">

                    <button data-dismiss="modal" class="close" type="button"></button>

                    <h3>portlet Settings</h3>

                </div>

                <div class="modal-body">

                    <p>Here will be a configuration form</p>

                </div>

            </div>

            <!-- END SAMPLE PORTLET CONFIGURATION MODAL FORM-->

            <!-- BEGIN PAGE CONTAINER-->        

            <div class="container-fluid">

                <!-- BEGIN PAGE HEADER-->

                <div class="row-fluid">

                    <div class="span12">

                        <!-- BEGIN STYLE CUSTOMIZER -->

                        <div class="color-panel hidden-phone">

                            <!-- <div class="color-mode-icons icon-color"></div> -->

                            <div class="color-mode-icons icon-color-close"></div>

                            <div class="color-mode">

                                <p>THEME COLOR</p>

                                <ul class="inline">

                                    <li class="color-black current color-default" data-style="default"></li>

                                    <li class="color-blue" data-style="blue"></li>

                                    <li class="color-brown" data-style="brown"></li>

                                    <li class="color-purple" data-style="purple"></li>

                                    <li class="color-grey" data-style="grey"></li>

                                    <li class="color-white color-light" data-style="light"></li>

                                </ul>

                                <label>

                                    <span>Layout</span>

                                    <select class="layout-option m-wrap small">

                                        <option value="fluid" selected>Fluid</option>

                                        <option value="boxed">Boxed</option>

                                    </select>

                                </label>

                                <label>

                                    <span>Header</span>

                                    <select class="header-option m-wrap small">

                                        <option value="fixed" selected>Fixed</option>

                                        <option value="default">Default</option>

                                    </select>

                                </label>

                                <label>

                                    <span>Sidebar</span>

                                    <select class="sidebar-option m-wrap small">

                                        <option value="fixed">Fixed</option>

                                        <option value="default" selected>Default</option>

                                    </select>

                                </label>

                                <label>

                                    <span>Footer</span>

                                    <select class="footer-option m-wrap small">

                                        <option value="fixed">Fixed</option>

                                        <option value="default" selected>Default</option>

                                    </select>

                                </label>

                            </div>

                        </div>

                        <!-- END BEGIN STYLE CUSTOMIZER -->  

                        <!-- BEGIN PAGE TITLE & BREADCRUMB-->

                        <h3 class="page-title">

                            文章列表

                        </h3>

                        <ul class="breadcrumb">

                            <li>

                                <i class="icon-home"></i>
                                <span>当前位置：</span>
                                <span>首页</span>
                                <i class="icon-angle-right"></i>
                            </li>
                            <li>
                                <span>文章管理</span>
                                <i class="icon-angle-right"></i>
                            </li>
                            <li><span>文章列表</span></li>
                        </ul>
                        <!-- END PAGE TITLE & BREADCRUMB-->

                        <div class="control-group clearfix">

                            <label class="control-label" style="float:left; line-height: 28px;">文章类型：</label>

                            <div class="controls" style="float:left;">
                    
                                <select class="small m-wrap" tabindex="1" id="type_select">
                                    <option value="0" class="type" >--选择文章类型--</option>
                  <?php 
                    foreach ($typicle_info as $key => $value) {
                        echo <<<EOF

                             <option value="{$value['article_type_id']}" class="type" data-id="{$value['article_type_id']}">{$value['name']}</option>

EOF;
                    }
                                  
                  ?>
                                </select>

                            </div>

                            <label class="control-label" style="float:left; line-height: 28px; margin-left:20px;">频道:</label>

                            <div class="controls" style="float:left;">
                    
                                <select class="small m-wrap" tabindex="1" id="channel_select">
                                    <option value="0" class="type" >--选择频道--</option>
                  <?php 
                    foreach ($channel_list as $key => $value) {
                        echo <<<EOF

                             <option value="{$value['article_type_id']}-{$value['name']}" class="type" >{$value['type_name']}--{$value['remark']}</option>

EOF;
                    }
                                  
                  ?>
                                </select>

                            </div>



                            <label class="control-label" style="float:left; line-height: 28px; margin-left: 50px;">状态：</label>

                            <div class="controls" style="float:left;">

                                <label class="checkbox">

                                <input type="checkbox" value="未推送" id="status_1" /> 未推送

                                </label>

                                <label class="checkbox">

                                <input type="checkbox" value="已推送" id="status_2" /> 已推送

                                </label>

                            </div>




                        </div>






                    </div>

                </div>
                <!-- END PAGE HEADER-->
                <!-- BEGIN PAGE CONTENT-->
                <div class="row-fluid">

                    <div class="span6 responsive" data-tablet="span12 fix-offset" data-desktop="span6" style="width:100%;">

                        <!-- BEGIN EXAMPLE TABLE PORTLET-->

                        <div class="portlet box grey">

                            <div class="portlet-title">

                                <div class="caption"><i class="icon-user"></i>文章列表</div>

                                <div class="actions controls">

                                    <a href="#form_modal_edit" data-toggle="modal" data-target="#form_modal_edit" id="pushBtn" class="btn blue"><i class="icon-pencil"></i>推送</a>
                                    <!--<a href="/Index/Authority/add" class="btn blue"><i class="icon-pencil"></i> 添加</a>-->

                                </div> 

                            </div>

                            <div class="portlet-body">

                                <table class="table table-striped table-bordered table-hover" id="current_table">

                                    <thead>

                                        <tr>
                                            <th>文章标题</th>
                                            <th>文章类型</th>
                                            <th>频道</th>
                                            <th>作者</th>
                                            <th>来源</th>
                                            <th>状态</th>
                                            <th>创建时间</th>
                                          
                                            <th>操作</th>
                                        </tr>

                                    </thead>
                                <tbody id="tbody">
<?php
    foreach ($article_list as $k => $v) {

        $style = (0 == ($k % 2)) ? 'odd' : 'even';
        echo <<< EOF
    <tr class="{$style} gradeX">

        <td><div class="check"><span><input name="checkBox" type="checkbox" class="selectCheckBox" data-id="{$v['article_id']}" data-tit="{$v['title']}" data-content='{$v["article_content"]}' data-author="{$v['author']}" data-source="{$v['source']}" data-time="{$v['current_time']}" data-push="{$v['push_time']}" data-picture="{$v['thumb']}" ></span></div><a class="modalbtn_art" data-toggle="modal" href="#art_con_modal">{$v['title']} </a>{$v['pic']}</td>
        <td>{$v['name']}</td>
        <td>{$v['chanel']}</td>
        <td>{$v['author']}</td>
        <td>{$v['source']}</td>
        <td>{$v['article_status']}</td>
        <td>{$v['current_time']}</td>
      
        <td ><a class="tableDelete" href="/Article/del/id/{$v['article_id']}">删除</a> / <a class="tableEdit" href="/Article/edit/id/{$v['article_id']}">修改</a></td>
    </tr>
EOF;
    }
?>
                                    </tbody>

                </table>

                <p><a href="#" id="chose1">全选</a> / <a href="#" id="chose2">反选</a></p>

                        <div id="pages">
                        <?php
                            if($article_list[0]['rows']/$article_list[0]['every_page']<=1 || empty($article_list))
                                {
                                    
                                }
                                else
                                {
                                    print_r($allpage);
                                }
                        ?>
                        </div>


                            </div>

                        </div>
                                       
        

            <div id="form_modal_edit" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel3" aria-hidden="true">

                <div class="modal-header">

                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>

                    <h3 id="myModalLabel3">文章推送</h3>

                </div>

                <div class="modal-body">

                <form action="#" id="form_article_edit" method="post" class="form-horizontal">
                    <div class="control-group">
                    
                        <label class="control-label">推送方式</label>
                    
                        <div class="controls">
                            <label class="control-push-label">
                                <input type="radio" class="m-wrap" name="push_style" value="1" checked="checked" id="manual"/>手动
                                <input type="radio" class="m-wrap" name="push_style" value="2" id="timer"/>定时
                                
                           </label>
                    
                        </div>
                    
                    </div> 

            <div class="control-group">
            
                <label class="control-label">推送网站</label>
            
                <div class="controls">
            
                    <select class="colorpicker-default m-wrap" name="push_address" id="push_address">
                        <option value="0">--请选择推送的网站--</option>
                    </select>
            
                </div>
            
            </div> 

            <div class="control-group">
            
                <label class="control-label">搜索栏目</label>
            
                <div class="controls">
                     <input type="text" style="width:160px;" name="demo" value="请输入搜索的栏目" onFocus="if (this.value=='请输入搜索的栏目') this.value='';">
                     <input type = "submit" value="搜索" id="search">
            
                </div>
            
            </div> 
            
             <div class="control-group">
            
                <label class="control-label">推送栏目</label>
            
                <div class="controls">
            
                    <select class="colorpicker-default m-wrap" name="push_Module"
                    id="pushOne_Module">
                    <option value="0">--请选择推送的栏目--</option>
<?php
    //foreach ($category_info AS $k => $v) {
        //echo '<option value="' . $v['category_id'] . '">' . $v['name'] . '</option>';
    //}
?> 
                                                    </select>
                                            
                                                </div>
                                            
                                            </div> 

                                            

                                            


            <div class="control-group" id="push_time" style="display: none;">
            
                <label class="control-label">推送时间</label>
            
                <div class="controls">
            
                   <input placeholder="请输入日期" class="laydate-icon" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" id="push_time_input" name="push_time_input">

                </div>
            
            </div> 
            <div class="control-group">
                <label class="control-label">所选内容</label>
                <div class="controls">
                <select  id="article_li" name="article_li">
                </select>
                 </div>
            </div>
            <div  style="display: none;" class="control-group">
                <label class="control-label">文章内容</label>
                <div class="controls">
                 <select  name="article_content" id="article_content">
                </select>
                </div>
            </div>
            <div  style="display: none;" class="control-group">
                <label class="control-label">文章作者</label>
                <div class="controls">
                 <select  name="article_author" id="article_author">
                </select>
                </div>
            </div>
           <div  style="display: none; " class="control-group">
               <label class="control-label">文章来源</label>
               <div class="controls" >
                <select  name="article_source" id="article_source">
                </select>
               </div>
           </div> 
            <div  style="display: none;" class="control-group">
                <label class="control-label">文章时间</label>
                <div class="controls">
                 <select  name="article_time" id="article_time">
                </select>
                </div>
            </div> 
            <div  style="display: none;" class="control-group">
                <label class="control-label">推送图片</label>
                <div class="controls">
                 <select  name="article_picture" id="article_picture">
                </select>
                </div>
            </div>

            <div  style="display: none;" class="control-group">
                <label class="control-label">推送地址</label>
                <div class="controls">
                    <input type="text" value="<?php echo 'http://'.$_SERVER['HTTP_HOST'];?>" id="article_url" name="article_url">
                 
                </div>
            </div>

        </form>

    </div>

        <div class="modal-footer">

            <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>

            <button class="btn green btn-primary" id="push_form" data-dismiss="modal">提交</button>
            
        </div>

    </div>

                        <!-- END EXAMPLE TABLE PORTLET-->

                    </div>

                </div>

                <!-- END PAGE CONTENT-->

            </div>

            <!-- END PAGE CONTAINER-->

        </div>
        <div id="art_con_modal" class="modal hide fade" tabindex="-1" data-width="760">
            
            <div class="modal-header">

                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>

                <h3 id="modal_tit"></h3>

            </div>

            <div class="modal-body">

                <div class="row-fluid" id="modal_con">

                </div>

            </div>

            <div class="modal-footer">

                <button type="button" data-dismiss="modal" class="btn">关闭</button>

            </div>

        </div>

    <!-- END PAGE -->
<?php
    include APPLICATION_PATH . '/application/views/foot.phtml';
?>
